<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>JUNCMS - CMD 命令行工具</title>
    </head>
    <link rel="stylesheet" type="text/css" href="__ADMIN__/css/cmd.css">
    <script type="text/javascript" src="__ADMIN__/css/codemirror/jquery.min.js"></script>
    
    <!--编辑器基础样式-->
    <link rel="stylesheet" href="__ADMIN__/css/codemirror/lib/codemirror.css">
    <script src="__ADMIN__/css/codemirror/lib/codemirror.js"></script>

    <!--引入css文件，用以支持主题-->
    <link rel="stylesheet" href="__ADMIN__/css/codemirror/theme/seti.css">

    <!--支持代码折叠-->
    <link rel="stylesheet" href="__ADMIN__/css/codemirror/addon/fold/foldgutter.css"/>
    <script src="__ADMIN__/css/codemirror/addon/fold/foldcode.js"></script>
    <script src="__ADMIN__/css/codemirror/addon/fold/foldgutter.js"></script>
    <script src="__ADMIN__/css/codemirror/addon/fold/brace-fold.js"></script>
    <script src="__ADMIN__/css/codemirror/addon/fold/comment-fold.js"></script>

    <!--全屏模式-->
    <link rel="stylesheet" href="__ADMIN__/css/codemirror/addon/display/fullscreen.css">
    <script src="__ADMIN__/css/codemirror/addon/display/fullscreen.js"></script>

    <!--括号匹配-->
    <script src="__ADMIN__/css/codemirror/addon/edit/matchbrackets.js"></script>

    <!--高亮库-->
    <script src="__ADMIN__/css/codemirror/mode/htmlmixed/htmlmixed.js"></script>
    <script src="__ADMIN__/css/codemirror/mode/clike/clike.js"></script>

    <script src="__ADMIN__/css/codemirror/mode/javascript/javascript.js"></script>

    <script src="__ADMIN__/css/codemirror/mode/css/css.js"></script>
    <script src="__ADMIN__/css/codemirror/mode/php/php.js"></script>
    <script src="__ADMIN__/css/codemirror/mode/xml/xml.js"></script>
    <script src="__ADMIN__/css/codemirror/mode/sql/sql.js"></script>
    <script src="__ADMIN__/css/codemirror/mode/htmlmixed/htmlmixed.js"></script>
    <!--自动补全库-->
    <link rel="stylesheet" href="__ADMIN__/css/codemirror/addon/hint/show-hint.css">

    <script src="__ADMIN__/css/codemirror/addon/hint/show-hint.js"></script>
    <script src="__ADMIN__/css/codemirror/addon/hint/javascript-hint.js"></script>
    <script src="__ADMIN__/css/codemirror/addon/hint/html-hint.js"></script>
    <script src="__ADMIN__/css/codemirror/addon/hint/xml-hint.js"></script>
    <script src="__ADMIN__/css/codemirror/addon/hint/css-hint.js"></script>
    <script src="__ADMIN__/css/codemirror/addon/hint/sql-hint.js"></script>
    
<body>
    <!--打开使用手册-->
    <div id="cmd_whole">查看命令行大全</div>

    <!--命令行操作界面-->
    <div class="cmd" contenteditable="true" style="word-wrap:break-word;word-break:break-all;">
        <div contenteditable="false">欢迎使用juncms-CMD 命令行工具 (^.^)</div>
        <div><span class="command-line" contenteditable="false">command line：></span>&nbsp;</div>
    </div>
    <!--代码编辑器操作页面-->
    <div class="code-upd"><textarea id="code"></textarea>
      <div class="code-bottom">
        <div class="vif-left"><span id="code-vif"></span></div>
        <button type="button" class="code-post">保存</button>
        <button type="button" class="code-out">退出</button>
      </div>


    </div>

</body>
</html>
<script type="text/javascript" src="__ADMIN__/js/juncmd.js"></script>
<script type="text/javascript">

// 查看命令行大全
$('#cmd_whole').click(function(){
    var html = $('.cmd').html();
    var txt = '';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 命令行工具当前版本 - V1.0.1.1</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 作者 - 小黄牛</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 邮箱 - 1731223728@qq.com</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 快捷键：ESC 清空当前界面，如果处于文件编辑器状态下，会退出编辑器</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 快捷键：F1  恢复清屏数据</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 快键键：编辑器状态下输入关键字之后按下Ctrl键，可以调起代码智能补齐提示</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 命令行介绍如下：</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 本工具是一个可嵌入在后台管理系统中的便捷式开发工具，适用于中小型项目，研发理念为，方便程序员的日常项目维护，正常状态下的程序调试；</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 本工具可用于商业用途，但不可随意更改作者著作权。</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 命令行使用说明：</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 初次使用命令行，系统提供了一个初始用户，账号密码：admin</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 使用命令行之前，需要先登录工具，进入页面后敲下回车，即可快捷弹出登录指令</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 每个命令行的提交都是使用【回车键】</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 命令行每个参数之间，都是用一个空格进行分割，例如登录指令：user login|name 账号 密码</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 命令行的组成方式：</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 主类 子类 参数1 参数2 参数N </div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 1、工具账号操作指令：</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 注册账号 : user reg 账号[必填] 密码[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 删除账号 : user del 账号[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 修改账号 : user upd 账号[必填] 密码[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 退出工具 : user exit</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 登录工具 : user login|name 账号[必填] 密码[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 查看管理员列表 : user -l 列举所有管理员</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 查看管理员日志 : user log 管理员账号[可选] (只有admin账号可以查看别人的日志)</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ (命令行工具的用户依赖文件作为存储方式，存放地址为：cmd/config/user/)</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 2、工具配置操作指令：</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 新增配置 : conf add 键名[必填] 值[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 修改配置 : conf upd 键名[必填] 值[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 删除配置 : conf del 键名[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 查看单个配置 : conf sel 键名[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 列举所有配置 : conf -l</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ (命令行工具的配置为一维数组，存放地址为：cmd/config/config.php)</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 3、MySql数据库操作指令：</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 检测MySql链接 my -g</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 执行CURD命令  my -x SQL语句[必填] -回滚标识[可选]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 数据库分卷备份 my -b 表名或分卷大小,必须是整数[可选] 分卷大小M,必须是整数[可选]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 数据库备份恢复(选择v1开头的版本，会自动恢复所有分卷) my -i sql文件名，不带文件夹[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 数据库备份打包与下载 my -z sql文件名，不带文件夹[必填]  是否需要下载,不为空即可[可选]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 列举出所有表名 my -l</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 查看指定单表的详细信息 my -ll 表名[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 注意：在使用my指令之前，应该使用conf指令修改工具配置文件中的数据库配置信息</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 注意：my -x指令 暂只支持：select delete update insert 四种SQL语句</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 4、PHP环境的相关操作指令：</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 打印服务器基本配置 : php -w</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 打印服务器已编译模块 : php -c</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 打印PHP系统相关参数 : php -l</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 打印PHP相关组件扩展 : php -z</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 打印数据库相关扩展与配置参数 : php -m</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 5、目录的相关操作指令：</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 简单的列举目录下的所有文件 mk -l 目录路径[可选]  不填的情况下使用配置文件中的根目录</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 详细的列举目录下的所有文件 mk -ll 目录路径[可选]  不填的情况下使用配置文件中的根目录</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 相对于配置文件下，新增目录 mk -a 新增目录的路径包含目录名[必填] 0755权限[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 自定义路径下，新增目录 mk -a 目标路径[必填] 相对目标路径新增目录的路径包含目录名[必填] 0755权限[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 检测目录是否存在 mk -s 检测路径[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 检测目录是否存在，若不存在则创建目录 mk -s 检测路径[必填] -y[必填] 0755权限[必填] </div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 删除目录 mk -d 目录路径[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 修改目录名 mk -u 原始路径[必填]  目标路径[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 6、文件的相关操作指令：</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 删除文件 tk -d 文件路径[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 检测文件是否存在 tk -s 文件路径[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 修改文件名 tk -u 原始文件路径[必填]  目标文件路径[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 复制文件 tk -c 原始文件路径[必填]  目标文件路径[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 7、Txt和Log文件的相关操作指令：</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 读取内容 txt -l 文件路径[必填] 读取函数，最大100[可选]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 替换内容 txt -t 文件路径[必填] 原始字符串[必填] 目标字符串[可选]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 8、数据库回滚的相关操作指令：</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 释放回滚标识 back get -回滚标识[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 删除回滚标识 back del -回滚标识[必填]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 列举回滚目录 back -l</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 9、文件检测与漏洞扫描指令：</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 检测与修复BOM头 loo bom 是否自动修复[可选]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 扫描文件代码是否存在安全隐藏 loo vif false或需要不被扫描的目录，用|符合隔开；当为false时禁用系统默认的绕过目录[可选]</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';   
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 10、代码文件编辑：</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ cd 路径[必填]      进入目录或打开文件，输入cd /直接进入配置CD_PATH的根目录</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ cd -h             查看cd命令当前所在的目录</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ cd -ls            查看cd命令当前所在目录下的所有文件</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';   
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ config.php配置文件的一些系统项说明：</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 数据库类型 : DB_TYPE</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 数据库地址 : DB_HOST</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 数据库名称 : DB_NAME</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 数据库账号 : DB_USER</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 数据库密码 : DB_PWD</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 数据库端口 : DB_PORT</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 数据库编码 : DB_CHARSET</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+ 命令行可操作的根目录 : CD_PATH</div>';
    txt += '<div contenteditable="false"><span class="command-cmd">CMD：></span>&nbsp;+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>';
    txt += '<div><span class="command-line" contenteditable="false">command line：></span>&nbsp;';
    $('.cmd').html(html+txt);
    // 设置光标到末尾
    var html = $('.cmd').html();
    $('.cmd').html('');
    $('.cmd').focus(); 
    Focus(html);
    $('.cmd').append('</div>');
});



function cmd_code(model){
    if(model == 'php') {
        model = 'application/x-httpd-php';
    }else if(model == 'xml') {
        model = 'text/xml';
    }else if(model == 'js') {
        model = 'text/javascript';
    }else if(model == 'css') {
        model = 'text/css';
    }else if(model == 'sql') {
        model = 'text/x-sql';
    }else{
        model = 'text/html';
    }
    
    var type   = {
        // 高亮显示-关联着自动补齐
        /**
         * application/x-httpd-php
         * text/css
         * text/javascript
         * text/html
         * text/x-sql
        */
        mode:'application/x-httpd-php',

        //显示行号
        lineNumbers:true,

        //设置主题
        theme:"seti",

        //代码折叠
        lineWrapping:true,
        foldGutter: true,
        gutters:["CodeMirror-linenumbers", "CodeMirror-foldgutter"],

        //全屏模式
        fullScreen:true,

        //括号匹配
        matchBrackets:true,
        completeSingle: false,
        selectionPointer: true,
        // 按下ctrl键唤起智能提示
        extraKeys:{
            "Ctrl": "autocomplete",
        }
    };
    var editor = CodeMirror.fromTextArea(document.getElementById("code"), type);

    // 满足自动触发自动联想功能 
    document.onkeydown=function(e){
        e=window.event||e;
        switch(e.keyCode){
            case 8:  break;//删除键
            case 13: break;//回车键
            case 27: 
            case 96: break;//清屏键
            case 37: break;//左键
            case 38: break;//向上键
            case 39: break;//右键
            case 40: break;//向下键
            default:
                if($('.code-upd').css('display') == 'block'){
                    editor.showHint();
                }
            break;
        }
    }

    // 提交文件保存更新
    $(".code-post").click(function(){
        $.ajax( {    
            url:'{:url("index")}', // 路径相对于当前目录，而不是项目根目录
            data:{    
                'type':'upd',
                'content':editor.getValue()
            },    
            type:'post',    
            cache:false,      
            success:function(data) {
                // alert(data);
                var obj  = eval('('+data+')');  
                // 抛出异常
                if(!obj.code){alert(data);}

                if(obj.code == '00' || obj.code == '01'){
                    prompt({'Id':'code-vif','Content':obj.data});
                }else if(obj.code == '02'){
                    code_out();
                    var html = $('.cmd').html();
                    $('.cmd').html(html+'<div contenteditable="false"><span class="command-echo">command Eco：></span>&nbsp;'+obj.data+'</div>');
                    var html = $('.cmd').html();
                    $('.cmd').html(html+'<div><span class="command-line" contenteditable="false">command line：></span>&nbsp;user login|name&nbsp;');
                    // 设置光标到末尾
                    var html = $('.cmd').html();
                    $('.cmd').html('');
                    $('.cmd').focus(); 
                    Focus(html);
                    $('.cmd').append('</div>');
                    $('.cmd').scrollTop( $('.cmd')[0].scrollHeight );
                }
            }, error : function(){
                alert("路径异常！");    
            }    
        }); 
    });
}

// 点击URL，提交获取文件内容
/*
$(document).on('click','body span', function(){
    var file = $(this).html();
	$.ajax( {    
        url:'{:url("index")}', // 路径相对于当前目录，而不是项目根目录
        data:{    
            'type':'click',
            'url':file
        },    
        type:'post',    
        cache:false,      
        success:function(data) {
            var obj  = eval('('+data+')');  
            // 抛出异常
            if(!obj.code){alert(data);}
            if(obj.code == '05'){
                $('#code').val(obj.data);
                $(".code-upd").fadeIn(1000);  
                cmd_code(obj.msg);
            }else if(obj.code == '02'){
                code_out();
                var html = $('.cmd').html();
                $('.cmd').html(html+'<div contenteditable="false"><span class="command-echo">command Eco：></span>&nbsp;'+obj.data+'</div>');
                var html = $('.cmd').html();
                $('.cmd').html(html+'<div><span class="command-line" contenteditable="false">command line：></span>&nbsp;');
                // 设置光标到末尾
                var html = $('.cmd').html();
                $('.cmd').html('');
                $('.cmd').focus(); 
                Focus(html);
                $('.cmd').append('</div>');
                $('.cmd').scrollTop( $('.cmd')[0].scrollHeight );
            }else if(obj.code == '02'){
                code_out();
                var html = $('.cmd').html();
                $('.cmd').html(html+'<div contenteditable="false"><span class="command-echo">command Eco：></span>&nbsp;'+obj.data+'</div>');
                var html = $('.cmd').html();
                $('.cmd').html(html+'<div><span class="command-line" contenteditable="false">command line：></span>&nbsp;user login|name&nbsp;');
                // 设置光标到末尾
                var html = $('.cmd').html();
                $('.cmd').html('');
                $('.cmd').focus(); 
                Focus(html);
                $('.cmd').append('</div>');
                $('.cmd').scrollTop( $('.cmd')[0].scrollHeight );
            }
        }, error : function(){
            alert("路径异常！");    
        }    
    }); 
});
*/
// 监听回车事件
$(document).keypress(function(e) {
    if(e.which == 13) {
        var html = '<span class="command-line" contenteditable="false">command line：&gt;</span>&nbsp;';
        var txt  = $('.cmd div:last').html().replace(html,'');

        // 发现火狐浏览器的bug，先暂停火狐浏览器的使用
        if (navigator.userAgent.indexOf("Firefox") > 0) {
            var html = $('.cmd').html();
            $('.cmd').html(html+'<div contenteditable="false"><span class="command-echo">command Eco：></span>&nbsp;已发现火狐浏览器BUG，暂不支持火狐浏览器使用！</div>');
            // 设置光标到末尾
            var html = $('.cmd').html();
            $('.cmd').html('');
            $('.cmd').focus(); 
            Focus(html);
            $('.cmd').append('</div>');
            return false;
        }

        var html = $('.cmd').html();
        $('.cmd').html(html+'<div contenteditable="false"><span class="command-echo">command Eco：></span>&nbsp;系统请求中，请耐心等候...</div>');
        
        $.ajax( {    
            url:'{:url("index")}', // 路径相对于当前目录，而不是项目根目录
            data:{    
                'cmd':txt    
            },    
            type:'post',    
            cache:false,      
            success:function(data) {
                // alert(data);
                var obj  = eval('('+data+')');  
                // 抛出异常
                if(!obj.code){alert(data);}
                // 未登录
                if(obj.code == 02){
                    var html = $('.cmd').html();
                    $('.cmd').html(html+'<div contenteditable="false"><span class="command-echo">command Eco：></span>&nbsp;'+obj.data+'</div>');
                    var html = $('.cmd').html();
                    $('.cmd').html(html+'<div><span class="command-line" contenteditable="false">command line：></span>&nbsp;user login|name&nbsp;');

                }else{ // 已登录
                    if($.isArray(obj.data)){
                        for(var i=0;i < obj.data.length;i++){
                            var html = $('.cmd').html();
                            $('.cmd').html(html+'<div contenteditable="false"><span class="command-echo">command Eco：></span>&nbsp;'+obj.data[i]+'</div>');
                        }
                    }else{
                        var html = $('.cmd').html();
						if(obj.code == 04){
							$('.cmd').html(html+'<div contenteditable="false"><span class="command-echo">command Eco：></span>&nbsp;已成功进入目录：'+obj.data+'</div>');
						}else if(obj.code == 05){
							$('#code').val(obj.data);
							$(".code-upd").fadeIn(1000);  
							cmd_code(obj.msg);
                        }else if(obj.code == 06){
                            $('.cmd').html(html+'<div contenteditable="false"><span class="command-echo">command Eco：></span>&nbsp;当前存在目录：'+obj.data+'</div>');
                        }else{
							$('.cmd').html(html+'<div contenteditable="false"><span class="command-echo">command Eco：></span>&nbsp;'+obj.data+'</div>');
						}
                    }
                
                    $('.cmd').focus(); 
                    var html = $('.cmd').html();
                    if(obj.code == '01'){
                        $('.cmd').html(html+'<div><span class="command-line" contenteditable="false">command line：></span>&nbsp;'+txt);
                    }else{
                        $('.cmd').html(html+'<div><span class="command-line" contenteditable="false">command line：></span>&nbsp;');
                    }

                }  

                // 判断是否有下载输出
                if(obj.dow){
                    window.open(obj.dow);
                }

                // 设置光标到末尾
                var html = $('.cmd').html();
                $('.cmd').html('');
                $('.cmd').focus(); 
                Focus(html);
                $('.cmd').append('</div>');

                $('.cmd').scrollTop( $('.cmd')[0].scrollHeight );
            }, error : function(){
                alert("路径异常！");    
            }    
        }); 

        return false;
    } 
}); 

</script>